package com.sxt.bus.controller;


import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sxt.bus.domain.Inport;
import com.sxt.bus.service.IInportService;
import com.sxt.bus.service.IOutportService;
import com.sxt.bus.vo.OutportVo;
import com.sxt.sys.domain.User;
import com.sxt.sys.utils.ResultObj;
import com.sxt.sys.utils.WebUtils;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 老雷
 * @since 2019-08-14
 */
@RestController
@RequestMapping("/outport")
public class OutportController {
	
	
	@Autowired
	private IInportService inportService;
	
	@Autowired
	private IOutportService outportService;
	

	@RequestMapping("addOutPort")
	public ResultObj addOutPort(OutportVo outportVo)
	{
		try {
			User user=(User) WebUtils.getHttpSession().getAttribute("user");
			//根据outportVo里面的id查询出进货的数据
			Inport inport=inportService.getById(outportVo.getId());
			outportVo.setProviderid(inport.getProviderid());
			outportVo.setPaytype(inport.getPaytype());
			outportVo.setOutputtime(new Date());
			outportVo.setOutportprice(inport.getInportprice());
			outportVo.setOperateperson(user.getName());
			outportVo.setGoodsid(inport.getGoodsid());
			this.outportService.save(outportVo);
			return ResultObj.ADD_SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			return ResultObj.ADD_ERROR;
		}

	}
	
}
